﻿using System;
using System.Drawing;

namespace Spencen.Mobile.Markup.Converters
{
    public class ColorConverter : Converter<Color>
    {
        public override Color ConvertFromString( string input, Type toType )
        {
            if ( string.IsNullOrEmpty( input ) )
                return Color.Transparent;

            // TODO: Well known names?

            var rgb = input.Split( ',' );
            return Color.FromArgb( int.Parse( rgb[ 0 ] ), int.Parse( rgb[ 1 ] ), int.Parse( rgb[ 2 ] ) );
        }
    }
}
